package com.loong.framework.utils;

import org.springframework.web.multipart.MultipartFile;

public class FileUploadUtil {
  /**
   * Checks if the given file is an image file.
   *
   * @param file the file to be checked
   * @return true if the file is an image file, false otherwise
   */
  public static boolean isImageFile(MultipartFile file) {
    String fileName = file.getOriginalFilename();
    return fileName != null
        && (fileName.endsWith(".jpg")
            || fileName.endsWith(".jpeg")
            || fileName.endsWith(".png")
            || fileName.endsWith(".gif")
            || fileName.endsWith(".bmp")
            || fileName.endsWith(".webp")
            || fileName.endsWith(".ico")
            || fileName.endsWith(".svg")
            || fileName.endsWith(".tiff")
            || fileName.endsWith(".tif")
            || fileName.endsWith(".jfif")
            || fileName.endsWith(".avif")
            || fileName.endsWith(".apng"));
  }
}
